import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

iris = load_iris()
# print('数据集中特征值是:\n', iris.data)
# print('数据集中目标值是:\n', iris['target'])
# print('数据集中特征名是:\n', iris.feature_names)
# print('数据集中目标名是:\n', iris.target_names)
# print('数据集的描述:\n', iris.DESCR)

# 数据可视化
# 数据类型转换
iris_data = pd.DataFrame(data=iris.data, columns=iris.feature_names)
iris_data['target'] = iris.target
# print(iris_data)


def iris_plot(data, col1, col2):
    sns.lmplot(x=col1, y=col2, data=data, hue='target')
    plt.title('datashow')
    plt.show()


iris_plot(data=iris_data, col1='sepal length (cm)', col2='petal width (cm)')

x_train, x_test, y_train, y_test = train_test_split(iris.data, iris_data.target, test_size=0.2)

print(x_train)
print('==================')
print(x_test)
print('==================')

print(y_train)
print('==================')
print(y_test)
print('==================')